{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# OpenDataTools 支持房地产价格数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入realestate接口\n",
    "from opendatatools import realestate\n",
    "realestate.set_proxies({\"https\" : \"https://127.0.0.1:1080\"})"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 基本数据规范"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['北京市', '上海市'])\n"
     ]
    }
   ],
   "source": [
    "# 获取城市列表\n",
    "city_list = realestate.get_city_list()\n",
    "print(city_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dict_keys(['东城', '西城', '朝阳', '海淀', '丰台', '石景山', '通州', '昌平', '大兴', '亦庄', '顺义', '房山', '门头沟', '平谷', '怀柔', '密云', '延庆', '浦东', '闵行', '宝山', '徐汇', '普陀', '杨浦', '长宁', '松江', '嘉定', '黄浦', '静安', '闸北', '虹口', '青浦', '奉贤', '金山', '崇明'])\n"
     ]
    }
   ],
   "source": [
    "# 获取区域列表\n",
    "district_list = realestate.get_district_list()\n",
    "print(district_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据接口"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100% (10 of 10) |########################| Elapsed Time: 0:00:19 ETA:  00:00:00"
     ]
    }
   ],
   "source": [
    "# 获取二手房信息\n",
    "df = realestate.get_esf_list_lianjia('北京市', max_page_no = 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>area</th>\n",
       "      <th>building</th>\n",
       "      <th>direction</th>\n",
       "      <th>elevator</th>\n",
       "      <th>floor</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>name</th>\n",
       "      <th>quality</th>\n",
       "      <th>shape</th>\n",
       "      <th>title</th>\n",
       "      <th>total_price</th>\n",
       "      <th>unit_price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>71.49平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>中楼层(共7层</td>\n",
       "      <td>101102985230</td>\n",
       "      <td>2000年建板楼</td>\n",
       "      <td>名佳花园一区</td>\n",
       "      <td>简装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>南北通透，把边四层正规两居室，诚心出售</td>\n",
       "      <td>335万</td>\n",
       "      <td>单价46860元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>159.23平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>中楼层(共14层</td>\n",
       "      <td>101102947347</td>\n",
       "      <td>2001年建板楼</td>\n",
       "      <td>嘉铭桐城A区</td>\n",
       "      <td>简装</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>满五年家庭名下一套房子，南北通透，全明格局</td>\n",
       "      <td>1380万</td>\n",
       "      <td>单价86668元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>53.77平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>高楼层(共6层</td>\n",
       "      <td>101102906880</td>\n",
       "      <td>1980年建板楼</td>\n",
       "      <td>永泰园</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>永泰园满5年唯一正规小两居，户型好有钥匙，随时签约</td>\n",
       "      <td>398万</td>\n",
       "      <td>单价74019元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>105.31平米</td>\n",
       "      <td></td>\n",
       "      <td>西南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>底层(共24层</td>\n",
       "      <td>101102898528</td>\n",
       "      <td>2004年建塔楼</td>\n",
       "      <td>乐城</td>\n",
       "      <td>简装</td>\n",
       "      <td>3室1厅</td>\n",
       "      <td>西南三居房本满五年，业主在京无其他房产</td>\n",
       "      <td>780万</td>\n",
       "      <td>单价74068元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>140.36平米</td>\n",
       "      <td></td>\n",
       "      <td>东南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>高楼层(共26层</td>\n",
       "      <td>101102920585</td>\n",
       "      <td>2003年建塔楼</td>\n",
       "      <td>九台2000家园</td>\n",
       "      <td>精装</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>九台2000家园 3室2厅 990万</td>\n",
       "      <td>990万</td>\n",
       "      <td>单价70533元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>54.81平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>低楼层(共6层</td>\n",
       "      <td>101102954631</td>\n",
       "      <td>1991年建板楼</td>\n",
       "      <td>小关东街</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>NEW上惠新小关VIP聚焦房源②层满五年家庭唯一可签</td>\n",
       "      <td>420万</td>\n",
       "      <td>单价76629元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>77.48平米</td>\n",
       "      <td></td>\n",
       "      <td>南 西</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>底层(共6层</td>\n",
       "      <td>101102949916</td>\n",
       "      <td>2002年建板楼</td>\n",
       "      <td>诚苑南里</td>\n",
       "      <td>简装</td>\n",
       "      <td>1室1厅</td>\n",
       "      <td>诚苑南里，满5年家庭名下唯一住宅 随时可看</td>\n",
       "      <td>330万</td>\n",
       "      <td>单价42592元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>166.05平米</td>\n",
       "      <td></td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共18层</td>\n",
       "      <td>101102332357</td>\n",
       "      <td>2001年建塔楼</td>\n",
       "      <td>富润家园</td>\n",
       "      <td>精装</td>\n",
       "      <td>4室2厅</td>\n",
       "      <td>学院路 富润家园 精装修南向复式四居室 楼下有卧室</td>\n",
       "      <td>1360万</td>\n",
       "      <td>单价81904元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>93.25平米</td>\n",
       "      <td></td>\n",
       "      <td>东南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共34层</td>\n",
       "      <td>101102633605</td>\n",
       "      <td>2011年建板塔结合</td>\n",
       "      <td>天洋城</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>天洋城经典F7户型，满五年看房有钥匙业主诚心出售</td>\n",
       "      <td>196万</td>\n",
       "      <td>单价21019元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>68.1平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>中楼层(共6层</td>\n",
       "      <td>101102912169</td>\n",
       "      <td>1979年建板楼</td>\n",
       "      <td>北京林业大学校内</td>\n",
       "      <td>精装</td>\n",
       "      <td>3室1厅</td>\n",
       "      <td>林大家属区 南北通透正规三居 精装修 满五年唯一</td>\n",
       "      <td>646万</td>\n",
       "      <td>单价94861元/平米</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       area building direction elevator     floor            id    location  \\\n",
       "0   71.49平米                南 北      无电梯   中楼层(共7层  101102985230    2000年建板楼   \n",
       "1  159.23平米                南 北      有电梯  中楼层(共14层  101102947347    2001年建板楼   \n",
       "2   53.77平米                南 北      无电梯   高楼层(共6层  101102906880    1980年建板楼   \n",
       "3  105.31平米                 西南      有电梯   底层(共24层  101102898528    2004年建塔楼   \n",
       "4  140.36平米                 东南      有电梯  高楼层(共26层  101102920585    2003年建塔楼   \n",
       "5   54.81平米                南 北      无电梯   低楼层(共6层  101102954631    1991年建板楼   \n",
       "6   77.48平米                南 西      无电梯    底层(共6层  101102949916    2002年建板楼   \n",
       "7  166.05平米                  南      有电梯  低楼层(共18层  101102332357    2001年建塔楼   \n",
       "8   93.25平米                 东南      有电梯  低楼层(共34层  101102633605  2011年建板塔结合   \n",
       "9    68.1平米                南 北      无电梯   中楼层(共6层  101102912169    1979年建板楼   \n",
       "\n",
       "       name quality shape                       title total_price   unit_price  \n",
       "0    名佳花园一区      简装  2室1厅         南北通透，把边四层正规两居室，诚心出售        335万  单价46860元/平米  \n",
       "1    嘉铭桐城A区      简装  3室2厅       满五年家庭名下一套房子，南北通透，全明格局       1380万  单价86668元/平米  \n",
       "2       永泰园      精装  2室1厅   永泰园满5年唯一正规小两居，户型好有钥匙，随时签约        398万  单价74019元/平米  \n",
       "3        乐城      简装  3室1厅         西南三居房本满五年，业主在京无其他房产        780万  单价74068元/平米  \n",
       "4  九台2000家园      精装  3室2厅          九台2000家园 3室2厅 990万        990万  单价70533元/平米  \n",
       "5      小关东街      精装  2室1厅  NEW上惠新小关VIP聚焦房源②层满五年家庭唯一可签        420万  单价76629元/平米  \n",
       "6      诚苑南里      简装  1室1厅       诚苑南里，满5年家庭名下唯一住宅 随时可看        330万  单价42592元/平米  \n",
       "7      富润家园      精装  4室2厅   学院路 富润家园 精装修南向复式四居室 楼下有卧室       1360万  单价81904元/平米  \n",
       "8       天洋城      精装  2室1厅    天洋城经典F7户型，满五年看房有钥匙业主诚心出售        196万  单价21019元/平米  \n",
       "9  北京林业大学校内      精装  3室1厅    林大家属区 南北通透正规三居 精装修 满五年唯一        646万  单价94861元/平米  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100% (3 of 3) |##########################| Elapsed Time: 0:00:04 ETA:  00:00:00"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>area</th>\n",
       "      <th>building</th>\n",
       "      <th>direction</th>\n",
       "      <th>elevator</th>\n",
       "      <th>floor</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>name</th>\n",
       "      <th>quality</th>\n",
       "      <th>shape</th>\n",
       "      <th>title</th>\n",
       "      <th>total_price</th>\n",
       "      <th>unit_price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>53.77平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>高楼层(共6层</td>\n",
       "      <td>101102906880</td>\n",
       "      <td>1980年建板楼</td>\n",
       "      <td>永泰园</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>永泰园满5年唯一正规小两居，户型好有钥匙，随时签约</td>\n",
       "      <td>398万</td>\n",
       "      <td>单价74019元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>166.05平米</td>\n",
       "      <td></td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共18层</td>\n",
       "      <td>101102332357</td>\n",
       "      <td>2001年建塔楼</td>\n",
       "      <td>富润家园</td>\n",
       "      <td>精装</td>\n",
       "      <td>4室2厅</td>\n",
       "      <td>学院路 富润家园 精装修南向复式四居室 楼下有卧室</td>\n",
       "      <td>1360万</td>\n",
       "      <td>单价81904元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>68.1平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>中楼层(共6层</td>\n",
       "      <td>101102912169</td>\n",
       "      <td>1979年建板楼</td>\n",
       "      <td>北京林业大学校内</td>\n",
       "      <td>精装</td>\n",
       "      <td>3室1厅</td>\n",
       "      <td>林大家属区 南北通透正规三居 精装修 满五年唯一</td>\n",
       "      <td>646万</td>\n",
       "      <td>单价94861元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>62.57平米</td>\n",
       "      <td></td>\n",
       "      <td>南</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>中楼层(共6层</td>\n",
       "      <td>101102951142</td>\n",
       "      <td>2004年建板楼</td>\n",
       "      <td>宝盛北里</td>\n",
       "      <td>精装</td>\n",
       "      <td>1室1厅</td>\n",
       "      <td>北里全南稀少大一居室，婚房装修 税费少 大阳台大窗户</td>\n",
       "      <td>428万</td>\n",
       "      <td>单价68404元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>80.87平米</td>\n",
       "      <td></td>\n",
       "      <td>西南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>底层(共9层</td>\n",
       "      <td>101102861075</td>\n",
       "      <td>2004年建板楼</td>\n",
       "      <td>蜂鸟家园</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>蜂鸟家园 西南两居 满五年 精装修</td>\n",
       "      <td>1090万</td>\n",
       "      <td>单价134785元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>80.8平米</td>\n",
       "      <td></td>\n",
       "      <td>西南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>高楼层(共18层</td>\n",
       "      <td>101102874783</td>\n",
       "      <td>1999年建塔楼</td>\n",
       "      <td>农科院</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>皂君庙 农科院西南大两居 电梯房朝向好</td>\n",
       "      <td>938万</td>\n",
       "      <td>单价116090元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>69平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>顶层(共5层</td>\n",
       "      <td>101102510289</td>\n",
       "      <td>1985年建板楼</td>\n",
       "      <td>小泥湾</td>\n",
       "      <td>简装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>满五唯一南北通透明厨明卫带客厅</td>\n",
       "      <td>636万</td>\n",
       "      <td>单价92174元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>57.41平米</td>\n",
       "      <td></td>\n",
       "      <td>南 北</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共21层</td>\n",
       "      <td>101102732745</td>\n",
       "      <td>1997年建塔楼</td>\n",
       "      <td>月季园</td>\n",
       "      <td>简装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>十号线牡丹园月季园满五唯一南北通透带电梯两居室</td>\n",
       "      <td>480万</td>\n",
       "      <td>单价83610元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>93.41平米</td>\n",
       "      <td></td>\n",
       "      <td>西南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>中楼层(共14层</td>\n",
       "      <td>101102917931</td>\n",
       "      <td>2011年建板塔结合</td>\n",
       "      <td>水云居</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>2011年次新商品房社区，花园水系环绕，新房拎包入住</td>\n",
       "      <td>850万</td>\n",
       "      <td>单价90997元/平米</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>66平米</td>\n",
       "      <td></td>\n",
       "      <td>西北</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>底层(共16层</td>\n",
       "      <td>101102863109</td>\n",
       "      <td>1992年建塔楼</td>\n",
       "      <td>牡丹园西里</td>\n",
       "      <td>精装</td>\n",
       "      <td>2室1厅</td>\n",
       "      <td>牡丹园西里 精装二居室可改小三居室</td>\n",
       "      <td>589万</td>\n",
       "      <td>单价89243元/平米</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       area building direction elevator     floor            id    location  \\\n",
       "0   53.77平米                南 北      无电梯   高楼层(共6层  101102906880    1980年建板楼   \n",
       "1  166.05平米                  南      有电梯  低楼层(共18层  101102332357    2001年建塔楼   \n",
       "2    68.1平米                南 北      无电梯   中楼层(共6层  101102912169    1979年建板楼   \n",
       "3   62.57平米                  南      无电梯   中楼层(共6层  101102951142    2004年建板楼   \n",
       "4   80.87平米                 西南      有电梯    底层(共9层  101102861075    2004年建板楼   \n",
       "5    80.8平米                 西南      有电梯  高楼层(共18层  101102874783    1999年建塔楼   \n",
       "6      69平米                南 北      无电梯    顶层(共5层  101102510289    1985年建板楼   \n",
       "7   57.41平米                南 北      有电梯  低楼层(共21层  101102732745    1997年建塔楼   \n",
       "8   93.41平米                 西南      有电梯  中楼层(共14层  101102917931  2011年建板塔结合   \n",
       "9      66平米                 西北      有电梯   底层(共16层  101102863109    1992年建塔楼   \n",
       "\n",
       "       name quality shape                       title total_price  \\\n",
       "0       永泰园      精装  2室1厅   永泰园满5年唯一正规小两居，户型好有钥匙，随时签约        398万   \n",
       "1      富润家园      精装  4室2厅   学院路 富润家园 精装修南向复式四居室 楼下有卧室       1360万   \n",
       "2  北京林业大学校内      精装  3室1厅    林大家属区 南北通透正规三居 精装修 满五年唯一        646万   \n",
       "3      宝盛北里      精装  1室1厅  北里全南稀少大一居室，婚房装修 税费少 大阳台大窗户        428万   \n",
       "4      蜂鸟家园      精装  2室1厅           蜂鸟家园 西南两居 满五年 精装修       1090万   \n",
       "5       农科院      精装  2室1厅         皂君庙 农科院西南大两居 电梯房朝向好        938万   \n",
       "6       小泥湾      简装  2室1厅             满五唯一南北通透明厨明卫带客厅        636万   \n",
       "7       月季园      简装  2室1厅     十号线牡丹园月季园满五唯一南北通透带电梯两居室        480万   \n",
       "8       水云居      精装  2室1厅  2011年次新商品房社区，花园水系环绕，新房拎包入住        850万   \n",
       "9     牡丹园西里      精装  2室1厅           牡丹园西里 精装二居室可改小三居室        589万   \n",
       "\n",
       "     unit_price  \n",
       "0   单价74019元/平米  \n",
       "1   单价81904元/平米  \n",
       "2   单价94861元/平米  \n",
       "3   单价68404元/平米  \n",
       "4  单价134785元/平米  \n",
       "5  单价116090元/平米  \n",
       "6   单价92174元/平米  \n",
       "7   单价83610元/平米  \n",
       "8   单价90997元/平米  \n",
       "9   单价89243元/平米  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取某个区域的二手房信息\n",
    "df = realestate.get_esf_list_by_distinct_lianjia('北京市', '海淀', max_page_no = 3)\n",
    "df.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100% (100 of 100) |######################| Elapsed Time: 0:02:00 ETA:  00:00:00"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>area</th>\n",
       "      <th>building</th>\n",
       "      <th>direction</th>\n",
       "      <th>elevator</th>\n",
       "      <th>floor</th>\n",
       "      <th>id</th>\n",
       "      <th>location</th>\n",
       "      <th>name</th>\n",
       "      <th>quality</th>\n",
       "      <th>shape</th>\n",
       "      <th>title</th>\n",
       "      <th>total_price</th>\n",
       "      <th>unit_price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>308.13平米</td>\n",
       "      <td>板楼</td>\n",
       "      <td>东 西</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共40层</td>\n",
       "      <td>107000236473</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>中粮海景壹号</td>\n",
       "      <td>精装</td>\n",
       "      <td>4室2厅</td>\n",
       "      <td>5020万入住中粮海景，享陆家嘴一线江景，钥匙房随时看</td>\n",
       "      <td>5020万</td>\n",
       "      <td>162919.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2000</th>\n",
       "      <td>379.88平米</td>\n",
       "      <td>2006年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>高楼层(共39层</td>\n",
       "      <td>107000155327</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>财富海景花园</td>\n",
       "      <td>毛坯</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>财富顶平   业主台湾人 随时签字 随时交房 随时看房</td>\n",
       "      <td>6078万</td>\n",
       "      <td>159998.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2452</th>\n",
       "      <td>29.72平米</td>\n",
       "      <td>1991年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>低楼层(共6层</td>\n",
       "      <td>107002234515</td>\n",
       "      <td>潍坊</td>\n",
       "      <td>泉东(二)小区</td>\n",
       "      <td>精装</td>\n",
       "      <td>1室1厅</td>\n",
       "      <td>明珠A，精装修一房，送12平天井，已改成卧室</td>\n",
       "      <td>455万</td>\n",
       "      <td>153096.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1999</th>\n",
       "      <td>349.34平米</td>\n",
       "      <td>2006年建板楼</td>\n",
       "      <td>西</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>高楼层(共39层</td>\n",
       "      <td>107000179947</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>财富海景花园</td>\n",
       "      <td>毛坯</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>前排高区，江景无di,业主诚意出售，毛坯</td>\n",
       "      <td>5240万</td>\n",
       "      <td>149998.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>204</th>\n",
       "      <td>346.87平米</td>\n",
       "      <td>2006年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共38层</td>\n",
       "      <td>107000052465</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>财富海景花园</td>\n",
       "      <td>精装</td>\n",
       "      <td>4室2厅</td>\n",
       "      <td>财富海景前排02户型品装 满五年唯一税低 保养九成新</td>\n",
       "      <td>5185万</td>\n",
       "      <td>149480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2945</th>\n",
       "      <td>3室2厅</td>\n",
       "      <td>2层板楼</td>\n",
       "      <td>174.12平米</td>\n",
       "      <td>精装</td>\n",
       "      <td>2层板楼</td>\n",
       "      <td>107000517059</td>\n",
       "      <td>碧云</td>\n",
       "      <td>云间绿大地</td>\n",
       "      <td>北</td>\n",
       "      <td>联排别墅</td>\n",
       "      <td>云间联排边套，花园占地大，装修保养好</td>\n",
       "      <td>2600万</td>\n",
       "      <td>149323.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>633</th>\n",
       "      <td>339.98平米</td>\n",
       "      <td>2006年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>中楼层(共38层</td>\n",
       "      <td>107000041673</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>财富海景花园</td>\n",
       "      <td>精装</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>永恒无遮挡江景，观百年外滩建筑群，格局方正采光明亮</td>\n",
       "      <td>4500万</td>\n",
       "      <td>132361.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>977</th>\n",
       "      <td>93.3平米</td>\n",
       "      <td>2006年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>无电梯</td>\n",
       "      <td>高楼层(共6层</td>\n",
       "      <td>107002229391</td>\n",
       "      <td>北蔡</td>\n",
       "      <td>大华锦绣华城(十九街区)(公寓)</td>\n",
       "      <td>精装</td>\n",
       "      <td>5室3厅</td>\n",
       "      <td>满五唯一省税+6复7送8+税费各付+贴心品质装修+赠露台</td>\n",
       "      <td>1200万</td>\n",
       "      <td>128618.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2290</th>\n",
       "      <td>122.1平米</td>\n",
       "      <td>2001年建板楼</td>\n",
       "      <td>西</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>中楼层(共27层</td>\n",
       "      <td>107002206717</td>\n",
       "      <td>陆家嘴</td>\n",
       "      <td>仁恒滨江园</td>\n",
       "      <td>精装</td>\n",
       "      <td>3室2厅</td>\n",
       "      <td>小区唯一朝南看全江景的小三房，陆家嘴地段，园林小区</td>\n",
       "      <td>1550万</td>\n",
       "      <td>126946.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2320</th>\n",
       "      <td>189.54平米</td>\n",
       "      <td>2003年建板楼</td>\n",
       "      <td>南</td>\n",
       "      <td>有电梯</td>\n",
       "      <td>低楼层(共7层</td>\n",
       "      <td>107000230249</td>\n",
       "      <td>花木</td>\n",
       "      <td>金色维也纳(公寓)</td>\n",
       "      <td>精装</td>\n",
       "      <td>7室3厅</td>\n",
       "      <td>金色维也纳(公寓) 7室3厅 2300万</td>\n",
       "      <td>2300万</td>\n",
       "      <td>121347.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          area  building direction elevator     floor            id location  \\\n",
       "13    308.13平米        板楼       东 西      有电梯  低楼层(共40层  107000236473      陆家嘴   \n",
       "2000  379.88平米  2006年建板楼         南      有电梯  高楼层(共39层  107000155327      陆家嘴   \n",
       "2452   29.72平米  1991年建板楼         南      无电梯   低楼层(共6层  107002234515       潍坊   \n",
       "1999  349.34平米  2006年建板楼         西      有电梯  高楼层(共39层  107000179947      陆家嘴   \n",
       "204   346.87平米  2006年建板楼         南      有电梯  低楼层(共38层  107000052465      陆家嘴   \n",
       "2945      3室2厅      2层板楼  174.12平米       精装      2层板楼  107000517059       碧云   \n",
       "633   339.98平米  2006年建板楼         南      有电梯  中楼层(共38层  107000041673      陆家嘴   \n",
       "977     93.3平米  2006年建板楼         南      无电梯   高楼层(共6层  107002229391       北蔡   \n",
       "2290   122.1平米  2001年建板楼         西      有电梯  中楼层(共27层  107002206717      陆家嘴   \n",
       "2320  189.54平米  2003年建板楼         南      有电梯   低楼层(共7层  107000230249       花木   \n",
       "\n",
       "                  name quality shape                         title  \\\n",
       "13              中粮海景壹号      精装  4室2厅   5020万入住中粮海景，享陆家嘴一线江景，钥匙房随时看   \n",
       "2000            财富海景花园      毛坯  3室2厅   财富顶平   业主台湾人 随时签字 随时交房 随时看房   \n",
       "2452           泉东(二)小区      精装  1室1厅        明珠A，精装修一房，送12平天井，已改成卧室   \n",
       "1999            财富海景花园      毛坯  3室2厅          前排高区，江景无di,业主诚意出售，毛坯   \n",
       "204             财富海景花园      精装  4室2厅    财富海景前排02户型品装 满五年唯一税低 保养九成新   \n",
       "2945             云间绿大地       北  联排别墅            云间联排边套，花园占地大，装修保养好   \n",
       "633             财富海景花园      精装  3室2厅     永恒无遮挡江景，观百年外滩建筑群，格局方正采光明亮   \n",
       "977   大华锦绣华城(十九街区)(公寓)      精装  5室3厅  满五唯一省税+6复7送8+税费各付+贴心品质装修+赠露台   \n",
       "2290             仁恒滨江园      精装  3室2厅     小区唯一朝南看全江景的小三房，陆家嘴地段，园林小区   \n",
       "2320         金色维也纳(公寓)      精装  7室3厅          金色维也纳(公寓) 7室3厅 2300万   \n",
       "\n",
       "     total_price  unit_price  \n",
       "13         5020万    162919.0  \n",
       "2000       6078万    159998.0  \n",
       "2452        455万    153096.0  \n",
       "1999       5240万    149998.0  \n",
       "204        5185万    149480.0  \n",
       "2945       2600万    149323.0  \n",
       "633        4500万    132361.0  \n",
       "977        1200万    128618.0  \n",
       "2290       1550万    126946.0  \n",
       "2320       2300万    121347.0  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 例子看看浦东最贵的房子在哪里\n",
    "df = realestate.get_esf_list_by_distinct_lianjia('上海市', '浦东', max_page_no = 100)\n",
    "df['unit_price'] = df['unit_price'].apply(lambda x : float(x.replace('单价', '').replace('元/平米', '')))\n",
    "df.sort_values('unit_price', ascending=False, inplace=True)\n",
    "df = df[df['unit_price'] >= 100000]\n",
    "df.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
